package com.baseproject;


import android.app.Activity;

import com.baseproject.entity.User;

import java.util.List;

import rx.Observable;

public class BaseProjectAppCofig implements IBaseProjectAppConfig{

    //代理模式,本类为代理类，app module中的AppConfig为真实类
    private static IBaseProjectAppConfig mBaseProjectAppConfig;

    private static BaseProjectAppCofig instance;

    private BaseProjectAppCofig(IBaseProjectAppConfig iBaseProjectAppConfig) {
        mBaseProjectAppConfig = iBaseProjectAppConfig;
    }

    public static BaseProjectAppCofig getInstance() {
        return instance;
    }

    public static BaseProjectAppCofig getInstance(IBaseProjectAppConfig iBaseProjectAppConfig) {
        if (null == instance) {
            synchronized (BaseProjectAppCofig.class) {
                if (null == instance) {
                    instance = new BaseProjectAppCofig(iBaseProjectAppConfig);
                }
            }
        }
        return instance;
    }

    public Class<?> getLoginActivityClass() {
        return mBaseProjectAppConfig.getLoginActivityClass();
    }

    @Override
    public Class<?> getMainActivityClass() {
        return mBaseProjectAppConfig.getMainActivityClass();
    }

    @Override
    public int getColorPrimary(Activity activity) {
        return mBaseProjectAppConfig.getColorPrimary(activity);
    }

    @Override
    public Observable<User> getUser() {
        return mBaseProjectAppConfig.getUser();
    }


    @Override
    public void updateUserState(int newState) {
        mBaseProjectAppConfig.updateUserState(newState);
    }

    @Override
    public List<Class> getDatabaseModelClasses() {
        return mBaseProjectAppConfig.getDatabaseModelClasses();
    }
}
